import { createWebHashHistory, createRouter } from 'vue-router'

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// import HomeView from '../pages/HomeView.vue'
// import GoodsListView from '../pages/GoodsListView.vue'
// import DetailView from '../pages/DetailView.vue'

const routes = [
  // 路由重定向
  { path: '/', redirect: '/ad' },
  { path: '/ad', component: () => import('../pages/AdView.vue'), },
  { path: '/test', component: () => import('../pages/testView.vue'), },
  {
    path: '/home',
    component: () => import('../pages/HomeView.vue'),
  },
  { path: '/goodslist', component: () => import('../pages/GoodsListView.vue') },
  { path: '/detail', component: () => import('../pages/DetailView.vue') },
]

const router = createRouter({
  // 路由模式
  history: createWebHashHistory(),
  // 路由配置项
  routes,
})

router.beforeEach((to, from) => {
  NProgress.start()
})

router.afterEach((to, from) => {
  NProgress.done()
})

export default router
